const express =require('express');
const router= express.Router()
const Mock=require('mockjs')
router.post('/',(req,res,next)=>{
  const {username,password} =req.body
  if((username === 'admin'|| username ==='user') && password === 'test'){
    const data = Mock.mock({
      username,
      nickname:'@ctitle(2)',
      avatar: '@image(64x64,@color,user)',
      token:'@guid',
      roles:[username]   //用户登录的的角色信息
    })
    res.json({
      code:200,
      data
    })
     
  }else{
    res.json({
      code:400,
      msg:'用户名或者密码错误'
    })
  }
})
router.delete('/',(req,res,next)=>{
  res.json({
    code:200,
    msg:'退出成功'
  })
})
module.exports = router